
#include "SelectionSort.h"
void SelectionSort(std::vector<TYPE> &nums,bool miniToMax)
{
    int mini = 0;
    for (int i = 0; i < nums.size() - 1; ++i) {
        mini = i;
        for (int j = i+1; j < nums.size(); ++j) {
            if(miniToMax){
                if(nums[j] < nums[mini]){
                    mini = j;
                }
            }else if(!miniToMax){
                if(nums[j] > nums[mini]){
                    mini = j;
                }
            }
        }
        std::swap(nums[i],nums[mini]);
    }
}
void show(std::vector<TYPE> &nums){
    std::cout<<"nums:";
    for (int i = 0; i < nums.size(); ++i) {
        std::cout<<nums[i]<<",";
    }std::cout<<std::endl;
}

int main(){
    std::vector<int> nums = {1,3,5,7,2,6,4,8,9,2,8,7,6,0,3,5,9,4,1,0};
    show(nums);
    SelectionSort(nums,true);
    show(nums);
    SelectionSort(nums, false);
    show(nums);
    return 0;
}